﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SharpCmd.Dialogs.Common
{
    internal partial class CommonTextBoxForm : Form
    {
        public CommonTextBoxForm()
        {
            InitializeComponent();
            DialogResult = DialogResult.Cancel;
        }

        /// <summary>
        /// Gets or sets the value displayed in Common Text Box Form
        /// </summary>
        public string Value
        {
            get { return tbName.Text; }
            set { tbName.Text = value; }
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        private void tbName_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
                buttonOK_Click(null, null);
            else if (e.KeyCode == Keys.Escape)
                Close();
        }
    }
}
